home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / TIcon.Frm < prev    next >
Text File  |  1997-06-14  |  15KB  |  492 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  3. Object = "*\APictureGlass.vbp"
  4. Begin VB.Form FTestIcons 
  5.    Caption         =   "Test Icons"
  6.    ClientHeight    =   6135
  7.    ClientLeft      =   1740
  8.    ClientTop       =   1590
  9.    ClientWidth     =   4620
  10.    Icon            =   "TIcon.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MousePointer    =   99  'Custom
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   6135
  15.    ScaleWidth      =   4620
  16.    Begin VB.CheckBox chkSmall 
  17.       BackColor       =   &H00FFFFFF&
  18.       Caption         =   "Small"
  19.       Height          =   330
  20.       Left            =   930
  21.       MaskColor       =   &H00FFFFFF&
  22.       Picture         =   "TIcon.frx":0442
  23.       TabIndex        =   19
  24.       Top             =   4770
  25.       Width           =   780
  26.    End
  27.    Begin PictureGlass.XPictureGlass pg 
  28.       Height          =   375
  29.       Left            =   480
  30.       TabIndex        =   18
  31.       Top             =   120
  32.       Width           =   375
  33.       _ExtentX        =   661
  34.       _ExtentY        =   661
  35.       BackColor       =   -2147483628
  36.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  37.          Name            =   "MS Sans Serif"
  38.          Size            =   8.25
  39.          Charset         =   0
  40.          Weight          =   400
  41.          Underline       =   0   'False
  42.          Italic          =   0   'False
  43.          Strikethrough   =   0   'False
  44.       EndProperty
  45.       ScaleWidth      =   375
  46.       ScaleMode       =   0
  47.       ScaleHeight     =   375
  48.    End
  49.    Begin VB.PictureBox pb 
  50.       Appearance      =   0  'Flat
  51.       AutoSize        =   -1  'True
  52.       BackColor       =   &H8000000A&
  53.       BorderStyle     =   0  'None
  54.       ForeColor       =   &H80000008&
  55.       Height          =   540
  56.       Index           =   0
  57.       Left            =   2892
  58.       ScaleHeight     =   540
  59.       ScaleWidth      =   1275
  60.       TabIndex        =   16
  61.       Top             =   516
  62.       Width           =   1275
  63.    End
  64.    Begin VB.PictureBox pb 
  65.       Appearance      =   0  'Flat
  66.       AutoSize        =   -1  'True
  67.       BackColor       =   &H8000000A&
  68.       BorderStyle     =   0  'None
  69.       ForeColor       =   &H80000008&
  70.       Height          =   540
  71.       Index           =   2
  72.       Left            =   2892
  73.       ScaleHeight     =   540
  74.       ScaleWidth      =   1275
  75.       TabIndex        =   11
  76.       Top             =   1830
  77.       Width           =   1275
  78.    End
  79.    Begin VB.PictureBox pb 
  80.       Appearance      =   0  'Flat
  81.       AutoSize        =   -1  'True
  82.       BackColor       =   &H8000000A&
  83.       BorderStyle     =   0  'None
  84.       ForeColor       =   &H80000008&
  85.       Height          =   540
  86.       Index           =   5
  87.       Left            =   2892
  88.       ScaleHeight     =   540
  89.       ScaleWidth      =   1275
  90.       TabIndex        =   3
  91.       Top             =   3810
  92.       Width           =   1275
  93.    End
  94.    Begin VB.PictureBox pb 
  95.       Appearance      =   0  'Flat
  96.       AutoSize        =   -1  'True
  97.       BackColor       =   &H8000000A&
  98.       BorderStyle     =   0  'None
  99.       ForeColor       =   &H80000008&
  100.       Height          =   540
  101.       Index           =   4
  102.       Left            =   2892
  103.       ScaleHeight     =   540
  104.       ScaleWidth      =   1275
  105.       TabIndex        =   2
  106.       Top             =   3150
  107.       Width           =   1275
  108.    End
  109.    Begin VB.PictureBox pb 
  110.       Appearance      =   0  'Flat
  111.       AutoSize        =   -1  'True
  112.       BackColor       =   &H8000000A&
  113.       BorderStyle     =   0  'None
  114.       ForeColor       =   &H80000008&
  115.       Height          =   540
  116.       Index           =   3
  117.       Left            =   2892
  118.       ScaleHeight     =   540
  119.       ScaleWidth      =   1275
  120.       TabIndex        =   1
  121.       Top             =   2490
  122.       Width           =   1275
  123.    End
  124.    Begin VB.PictureBox pb 
  125.       Appearance      =   0  'Flat
  126.       AutoSize        =   -1  'True
  127.       BackColor       =   &H8000000A&
  128.       BorderStyle     =   0  'None
  129.       ForeColor       =   &H80000008&
  130.       Height          =   540
  131.       Index           =   1
  132.       Left            =   2892
  133.       ScaleHeight     =   540
  134.       ScaleWidth      =   1275
  135.       TabIndex        =   0
  136.       Top             =   1170
  137.       Width           =   1275
  138.    End
  139.    Begin ComctlLib.ListView lstvwVB 
  140.       Height          =   810
  141.       Left            =   135
  142.       TabIndex        =   4
  143.       Top             =   5175
  144.       Width           =   1185
  145.       _ExtentX        =   2090
  146.       _ExtentY        =   1429
  147.       LabelWrap       =   -1  'True
  148.       HideSelection   =   -1  'True
  149.       _Version        =   327680
  150.       ForeColor       =   -2147483640
  151.       BackColor       =   -2147483643
  152.       Appearance      =   1
  153.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  154.          Name            =   "MS Sans Serif"
  155.          Size            =   8.25
  156.          Charset         =   0
  157.          Weight          =   400
  158.          Underline       =   0   'False
  159.          Italic          =   0   'False
  160.          Strikethrough   =   0   'False
  161.       EndProperty
  162.       MouseIcon       =   "TIcon.frx":2D24
  163.       NumItems        =   0
  164.    End
  165.    Begin ComctlLib.ListView lstvwFixed 
  166.       Height          =   810
  167.       Left            =   1440
  168.       TabIndex        =   15
  169.       Top             =   5190
  170.       Width           =   1245
  171.       _ExtentX        =   2196
  172.       _ExtentY        =   1429
  173.       LabelWrap       =   -1  'True
  174.       HideSelection   =   -1  'True
  175.       _Version        =   327680
  176.       ForeColor       =   -2147483640
  177.       BackColor       =   -2147483643
  178.       Appearance      =   1
  179.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  180.          Name            =   "MS Sans Serif"
  181.          Size            =   8.25
  182.          Charset         =   0
  183.          Weight          =   400
  184.          Underline       =   0   'False
  185.          Italic          =   0   'False
  186.          Strikethrough   =   0   'False
  187.       EndProperty
  188.       MouseIcon       =   "TIcon.frx":2D40
  189.       NumItems        =   0
  190.    End
  191.    Begin VB.Label lbl 
  192.       BackStyle       =   0  'Transparent
  193.       Caption         =   "ListView"
  194.       Height          =   255
  195.       Index           =   5
  196.       Left            =   135
  197.       TabIndex        =   20
  198.       Top             =   4815
  199.       Width           =   810
  200.    End
  201.    Begin VB.Image img 
  202.       Appearance      =   0  'Flat
  203.       Height          =   540
  204.       Index           =   0
  205.       Left            =   1284
  206.       Top             =   516
  207.       Width           =   1272
  208.    End
  209.    Begin VB.Label lbl 
  210.       BackStyle       =   0  'Transparent
  211.       Caption         =   "Basic:"
  212.       Height          =   432
  213.       Index           =   7
  214.       Left            =   324
  215.       TabIndex        =   17
  216.       Top             =   516
  217.       Width           =   852
  218.    End
  219.    Begin ComctlLib.ImageList imlstSmallFixed 
  220.       Left            =   2040
  221.       Top             =   6924
  222.       _ExtentX        =   794
  223.       _ExtentY        =   794
  224.       BackColor       =   -2147483643
  225.       _Version        =   327680
  226.    End
  227.    Begin ComctlLib.ImageList imlstLargeFixed 
  228.       Left            =   1404
  229.       Top             =   6924
  230.       _ExtentX        =   794
  231.       _ExtentY        =   794
  232.       BackColor       =   -2147483643
  233.       _Version        =   327680
  234.    End
  235.    Begin VB.Label lblData 
  236.       BackStyle       =   0  'Transparent
  237.       Height          =   855
  238.       Left            =   2880
  239.       TabIndex        =   14
  240.       Top             =   5145
  241.       Width           =   1770
  242.    End
  243.    Begin VB.Label lbl 
  244.       BackStyle       =   0  'Transparent
  245.       Caption         =   "Picture data:"
  246.       Height          =   330
  247.       Index           =   6
  248.       Left            =   2880
  249.       TabIndex        =   13
  250.       Top             =   4815
  251.       Width           =   1035
  252.    End
  253.    Begin VB.Image imgPattern 
  254.       Height          =   1920
  255.       Left            =   3165
  256.       Picture         =   "TIcon.frx":2D5C
  257.       Top             =   6795
  258.       Width           =   1920
  259.    End
  260.    Begin VB.Image img 
  261.       Appearance      =   0  'Flat
  262.       Height          =   540
  263.       Index           =   2
  264.       Left            =   1275
  265.       Top             =   1830
  266.       Width           =   1275
  267.    End
  268.    Begin VB.Label lbl 
  269.       BackStyle       =   0  'Transparent
  270.       Caption         =   "Shell Size:"
  271.       Height          =   432
  272.       Index           =   4
  273.       Left            =   300
  274.       TabIndex        =   12
  275.       Top             =   1830
  276.       Width           =   852
  277.    End
  278.    Begin VB.Label lbl 
  279.       BackStyle       =   0  'Transparent
  280.       Caption         =   "Image Size:"
  281.       Height          =   432
  282.       Index           =   3
  283.       Left            =   300
  284.       TabIndex        =   10
  285.       Top             =   2490
  286.       Width           =   876
  287.    End
  288.    Begin VB.Label lbl 
  289.       BackStyle       =   0  'Transparent
  290.       Caption         =   "Small:"
  291.       Height          =   432
  292.       Index           =   2
  293.       Left            =   300
  294.       TabIndex        =   9
  295.       Top             =   3150
  296.       Width           =   852
  297.    End
  298.    Begin VB.Label lbl 
  299.       BackStyle       =   0  'Transparent
  300.       Caption         =   "Huge:"
  301.       Height          =   432
  302.       Index           =   1
  303.       Left            =   300
  304.       TabIndex        =   8
  305.       Top             =   3810
  306.       Width           =   756
  307.    End
  308.    Begin VB.Label lbl 
  309.       BackStyle       =   0  'Transparent
  310.       Caption         =   "Default:"
  311.       Height          =   432
  312.       Index           =   0
  313.       Left            =   336
  314.       TabIndex        =   7
  315.       Top             =   1170
  316.       Width           =   852
  317.    End
  318.    Begin VB.Label lbl 
  319.       BackStyle       =   0  'Transparent
  320.       Caption         =   "Picture Boxes"
  321.       Height          =   330
  322.       Index           =   9
  323.       Left            =   2880
  324.       TabIndex        =   6
  325.       Top             =   84
  326.       Width           =   1275
  327.    End
  328.    Begin VB.Label lbl 
  329.       BackStyle       =   0  'Transparent
  330.       Caption         =   "Images"
  331.       Height          =   336
  332.       Index           =   8
  333.       Left            =   1260
  334.       TabIndex        =   5
  335.       Top             =   84
  336.       Width           =   1272
  337.    End
  338.    Begin ComctlLib.ImageList imlstLargeVB 
  339.       Left            =   96
  340.       Top             =   6924
  341.       _ExtentX        =   794
  342.       _ExtentY        =   794
  343.       BackColor       =   -2147483643
  344.       _Version        =   327680
  345.    End
  346.    Begin ComctlLib.ImageList imlstSmallVB 
  347.       Left            =   744
  348.       Top             =   6924
  349.       _ExtentX        =   794
  350.       _ExtentY        =   794
  351.       BackColor       =   -2147483643
  352.       _Version        =   327680
  353.    End
  354.    Begin VB.Image img 
  355.       Appearance      =   0  'Flat
  356.       Height          =   540
  357.       Index           =   5
  358.       Left            =   1275
  359.       Top             =   3810
  360.       Width           =   1275
  361.    End
  362.    Begin VB.Image img 
  363.       Appearance      =   0  'Flat
  364.       Height          =   540
  365.       Index           =   1
  366.       Left            =   1275
  367.       Top             =   1170
  368.       Width           =   1275
  369.    End
  370.    Begin VB.Image img 
  371.       Appearance      =   0  'Flat
  372.       Height          =   540
  373.       Index           =   3
  374.       Left            =   1275
  375.       Top             =   2490
  376.       Width           =   1275
  377.    End
  378.    Begin VB.Image img 
  379.       Appearance      =   0  'Flat
  380.       Height          =   540
  381.       Index           =   4
  382.       Left            =   1275
  383.       Top             =   3150
  384.       Width           =   1275
  385.    End
  386. End
  387. Attribute VB_Name = "FTestIcons"
  388. Attribute VB_GlobalNameSpace = False
  389. Attribute VB_Creatable = False
  390. Attribute VB_PredeclaredId = True
  391. Attribute VB_Exposed = False
  392.  
  393. Option Explicit
  394.  
  395. Private ctlLast As Control
  396. Private ctlCur As Control
  397.  
  398. Enum EIconPos
  399.     eipBasic = 0
  400.     eipDefault
  401.     eipShell
  402.     eipImage
  403.     eipSmall
  404.     eipHuge
  405. End Enum
  406.  
  407. Private Sub Form_Load()
  408.     If Not HasShell Then
  409.         MsgBox "This program requires the enhanced Windows user interface"
  410.         End
  411.     End If
  412.     
  413.     ' Load icon with Basic's LoadPicture (system metrics size)
  414.     Set img(eipBasic).Picture = LoadPicture("i.ico")
  415.     Set pb(eipBasic).Picture = LoadPicture("i.ico")
  416.     ' Load icon with Basic's LoadPicture (system metrics size)
  417.     Set img(eipDefault).Picture = LoadAnyPicture("i.ico", eisDefault)
  418.     Set pb(eipDefault).Picture = LoadAnyPicture("i.ico", eisDefault)
  419.     ' Load icon stretched to system metrics size
  420.     Set img(eipShell).Picture = LoadAnyPicture("i.ico", eisShell)
  421.     Set pb(eipShell).Picture = LoadAnyPicture("i.ico", eisShell)
  422.     ' Load first icon image in file with its real size
  423.     Set img(eipImage).Picture = LoadAnyPicture("i.ico", eisImage)
  424.     Set pb(eipImage).Picture = LoadAnyPicture("i.ico", eisImage)
  425.     ' Load small (16 by 16) icon, squashing if necessary
  426.     Set img(eipSmall).Picture = LoadAnyPicture("i.ico", eisSmall)
  427.     Set pb(eipSmall).Picture = LoadAnyPicture("i.ico", eisSmall)
  428.     ' Load huge (48 by 48) icon
  429.     Set img(eipHuge).Picture = LoadAnyPicture("i.ico", eisHuge)
  430.     Set pb(eipHuge).Picture = LoadAnyPicture("i.ico", eisHuge)
  431.     Set ctlLast = pb(eipBasic)
  432.     Set ctlCur = img(eipBasic)
  433.     PictureData
  434.     
  435.     ' Load small and large ImageLists and put in ListView
  436.     imlstSmallVB.ListImages.Add , , LoadPicture("i.ico")
  437.     imlstLargeVB.ListImages.Add , , LoadPicture("i.ico")
  438.     Set lstvwVB.SmallIcons = imlstSmallVB
  439.     Set lstvwVB.Icons = imlstLargeVB
  440.     lstvwVB.ListItems.Add , , "Basic", 1, 1
  441.     
  442.     imlstSmallFixed.ListImages.Add , , LoadAnyPicture("i.ico", eisSmall)
  443.     imlstLargeFixed.ListImages.Add , , LoadAnyPicture("i.ico", eisShell)
  444.     Set lstvwFixed.SmallIcons = imlstSmallFixed
  445.     Set lstvwFixed.Icons = imlstLargeFixed
  446.     lstvwFixed.ListItems.Add , , "Fixed", 1, 1
  447.     chkSmall_Click
  448.     chkSmall_Click
  449. End Sub
  450.  
  451. Private Sub Form_Paint()
  452.     bmpTile Me, imgPattern.Picture
  453. End Sub
  454.  
  455. Sub PictureData()
  456. With ctlCur
  457.     Dim s As String
  458.     ctlLast.BorderStyle = 0
  459.     ctlCur.BorderStyle = 1
  460.     s = s & "Picture Width: " & Int(ScaleX(.Picture.Width, 8, vbPixels)) & sCrLf
  461.     s = s & "Picture Height: " & Int(ScaleY(.Picture.Height, 8, vbPixels)) & sCrLf
  462.     s = s & TypeName(ctlCur) & " Width: " & Int(ScaleX(.Width, vbTwips, vbPixels)) & sCrLf
  463.     s = s & TypeName(ctlCur) & " Height: " & Int(ScaleY(.Height, vbTwips, vbPixels)) & sCrLf
  464.     lblData.Caption = s
  465. End With
  466. End Sub
  467.  
  468. Private Sub chkSmall_Click()
  469.     If chkSmall.Value = vbChecked Then
  470.         lstvwVB.View = lvwSmallIcon
  471.         lstvwFixed.View = lvwSmallIcon
  472.     Else
  473.         lstvwVB.View = lvwIcon
  474.         lstvwFixed.View = lvwIcon
  475.     End If
  476. End Sub
  477.  
  478. Private Sub img_Click(Index As Integer)
  479.     Set ctlLast = ctlCur
  480.     Set ctlCur = img(Index)
  481.     PictureData
  482. End Sub
  483.  
  484. Private Sub pb_Click(Index As Integer)
  485.     Set ctlLast = ctlCur
  486.     Set ctlCur = pb(Index)
  487.     PictureData
  488. End Sub
  489.  
  490.  
  491.  
  492.